/****************************************Copyright (c)**************************************************
**                                         2016-03
**
**                                
**
**
**--------------File Info-------------------------------------------------------------------------------
** File name:		    ht6x1x_tbs.h
** Last modified Date:  2016-03-29
** Last Version:		v1.0
** Descriptions:		
**
**------------------------------------------------------------------------------------------------------
** Created by:			Evan Chen
** Created date:		2016-03-29
** Version:				v1.0
** Descriptions:		
**
**------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
**
********************************************************************************************************/

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __HT6X1X_TBS_H
#define __HT6X1X_TBS_H

#ifdef __cplusplus
 extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "ht60xx.h"

#define TBS_VCC_MASK			((uint16_t)0x0010)
#define TBS_ADC1_MASK			((uint16_t)0x0008)
#define TBS_ADC0_MASK			((uint16_t)0x0004)
#define TBS_VBAT_MASK			((uint16_t)0x0002)
#define TBS_TMP_MASK			((uint16_t)0x0001)
#define TBS_ALL_MASK			((uint16_t)0x001F)

typedef enum
{
  	TBS_VCC = TBS_VCC_MASK,
	TBS_ADC1 = TBS_ADC1_MASK,
	TBS_ADC0 = TBS_ADC0_MASK,
	TBS_VBAT = TBS_VBAT_MASK,
	TBS_TMP = TBS_TMP_MASK,
	TBS_ALL = TBS_ALL_MASK,
} TBS_Enable_TypeDef;

/*TBSCON*/
#define TBSCON_FILTER_MASK       	((uint16_t)0x0300)
#define TBSCON_FILTER_1     		((uint16_t)0x0000)
#define TBSCON_FILTER_2       	((uint16_t)0x0100)
#define TBSCON_FILTER_4     		((uint16_t)0x0200)
#define TBSCON_FILTER_8       	((uint16_t)0x0300)

#define TBSCON_VCC_MASK       	((uint16_t)0x0010)
#define TBSCON_VCC_DIS     		((uint16_t)0x0000)
#define TBSCON_VCC_EN		       	((uint16_t)0x0010)

#define TBSCON_ADC1_MASK       	((uint16_t)0x0008)
#define TBSCON_ADC1_DIS     		((uint16_t)0x0000)
#define TBSCON_ADC1_EN		((uint16_t)0x0008)

#define TBSCON_ADC0_MASK       	((uint16_t)0x0004)
#define TBSCON_ADC0_DIS     		((uint16_t)0x0000)
#define TBSCON_ADC0_EN		((uint16_t)0x0004)

#define TBSCON_VBAT_MASK       	((uint16_t)0x0002)
#define TBSCON_VBAT_DIS     		((uint16_t)0x0000)
#define TBSCON_VBAT_EN		((uint16_t)0x0002)

#define TBSCON_TMP_MASK       	((uint16_t)0x0001)
#define TBSCON_TMP_DIS     		((uint16_t)0x0000)
#define TBSCON_TMP_EN			((uint16_t)0x0001)

/*TBSIE*/
#define TBSIE_VCC_MASK       		((uint16_t)0x0010)
#define TBSIE_VCC_DIS     		((uint16_t)0x0000)
#define TBSIE_VCC_EN		       	((uint16_t)0x0010)

#define TBSIE_ADC1_MASK       	((uint16_t)0x0008)
#define TBSIE_ADC1_DIS     		((uint16_t)0x0000)
#define TBSIE_ADC1_EN			((uint16_t)0x0008)

#define TBSIE_ADC0_MASK       	((uint16_t)0x0004)
#define TBSIE_ADC0_DIS     		((uint16_t)0x0000)
#define TBSIE_ADC0_EN			((uint16_t)0x0004)

#define TBSIE_VBAT_MASK       	((uint16_t)0x0002)
#define TBSIE_VBAT_DIS     		((uint16_t)0x0000)
#define TBSIE_VBAT_EN			((uint16_t)0x0002)

#define TBSIE_TMP_MASK       		((uint16_t)0x0001)
#define TBSIE_TMP_DIS     		((uint16_t)0x0000)
#define TBSIE_TMP_EN			((uint16_t)0x0001)

/*TBSPRD*/
#define TBSPRD_VCC_MASK       	((uint16_t)0x0600)
#define TBSPRD_VCC_1S     		((uint16_t)0x0000)
#define TBSPRD_VCC_2S		       	((uint16_t)0x0200)
#define TBSPRD_VCC_8S     		((uint16_t)0x0400)
#define TBSPRD_VCC_16S		((uint16_t)0x0600)

#define TBSPRD_ADC1_MASK       	((uint16_t)0x0180)
#define TBSPRD_ADC1_1S     		((uint16_t)0x0000)
#define TBSPRD_ADC1_2S		((uint16_t)0x0080)
#define TBSPRD_ADC1_8S     		((uint16_t)0x0100)
#define TBSPRD_ADC1_16S		((uint16_t)0x0180)

#define TBSPRD_ADC0_MASK       	((uint16_t)0x0060)
#define TBSPRD_ADC0_1S     		((uint16_t)0x0000)
#define TBSPRD_ADC0_2S		((uint16_t)0x0020)
#define TBSPRD_ADC0_8S     		((uint16_t)0x0040)
#define TBSPRD_ADC0_16S		((uint16_t)0x0060)

#define TBSPRD_VBAT_MASK       	((uint16_t)0x0018)
#define TBSPRD_VBAT_1S     		((uint16_t)0x0000)
#define TBSPRD_VBAT_2S		((uint16_t)0x0008)
#define TBSPRD_VBAT_8S     		((uint16_t)0x0010)
#define TBSPRD_VBAT_16S		((uint16_t)0x0018)

#define TBSPRD_TMP_MASK       	((uint16_t)0x0007)
#define TBSPRD_TMP_1F2S     		((uint16_t)0x0000)
#define TBSPRD_TMP_1S     		((uint16_t)0x0001)
#define TBSPRD_TMP_2S     		((uint16_t)0x0002)
#define TBSPRD_TMP_4S     		((uint16_t)0x0003)
#define TBSPRD_TMP_8S     		((uint16_t)0x0004)
#define TBSPRD_TMP_16S     		((uint16_t)0x0005)
#define TBSPRD_TMP_32S     		((uint16_t)0x0006)
#define TBSPRD_TMP_64S     		((uint16_t)0x0007)

void TBS_Enable(TBS_Enable_TypeDef  enable);
void TBS_Disable(TBS_Enable_TypeDef  enable);
void TBS_EnableInterrupt(TBS_Enable_TypeDef  enable);
void TBS_DisableInterrupt(TBS_Enable_TypeDef  enable);
void TBS_DisableInterruptAll(void);
void TBS_SetPerdic(uint16_t prd);

#ifdef __cplusplus
}
#endif

#endif /* __HT6X1X_TBS_H */

